package com.by.car.service.impl;

import com.by.car.entity.ShopCartItem;
import com.by.car.redis.RedisCartUtil;
import com.by.car.service.XxljobCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class XxljobCarServiceImpl implements XxljobCarService {

    // 获取当前用户ID（实际业务中应从登录信息获取，而非硬编码）!!!!!!!
    private static final int UserId = 23;
    @Autowired
    RedisCartUtil redisCartUtil;

    @Transactional
    @Override
    public int catToMysql() {

        //获取到redis数据
        List<ShopCartItem> itemList=redisCartUtil.selectCarItem(UserId);
        //判断是否长时间不操作
        for (ShopCartItem s:itemList) {

        }
        //是 存入mysql 并且 删除redis
        System.out.println("111111111111");
        return 0;
    }
}
